package com.study.crypto.basic.kafka.admin.component;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * @author Songjin
 * @since 2021-09-26 17:38
 */
@Component
public class KafkaConfig {
    
    @Value("${bootstrap.servers}")
    private String servers;
    
    /**
     * 配置Kafka
     *
     * @return
     */
    public Properties getProps() {
        Properties props = new Properties();
        props.put("bootstrap.servers", servers);
        /*// 重试次数
        props.put("retries", 2);
        // 批量发送大小
        props.put("batch.size", 16384);
        // 缓存大小，根据本机内存大小配置
        props.put("buffer.memory", 33554432);
        // 发送频率，满足任务一个条件发送
        props.put("linger.ms", 1000);*/
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        return props;
    }
    
}